#!/usr/bin/env bash

# Usage:
#   watchexec -e go -r -- ./run.sh

set -euo pipefail
# set -E

export TZ="Asia/Shanghai"
APP_ROOT=$(dirname "$(readlink -fm "$0")")
cd "${APP_ROOT}"

# if grep -f main-go &>/dev/null; then
#   kill $(pgrep -f main-go)
# fi

go build -o /tmp/main-go . && /tmp/main-go
# date -R

# !!! cmd
# watchexec -e go -r -- ./run.sh
# watchexec -e sh -- sh routers/curl.sh
# watchexec -c -r -e json -- bat -p -S /tmp/f111.json

# Flags
# -c --clear	Clear screen
# -r --restart	Restart process if its still running
# Options
# -s --signal SIGKILL	Kill signal to use
# -d --debounce MS	Debounce by MS milliseconds
# -e --exts EXTS	Extensions
# -i --ignore PATTERN	Ignore these files
# -w --watch PATH	Watch these directories

# watchexec --exts js,jsx -- npm test
# watchman -w lib -w test -- npm test

# Only run when files are created:
# $ watchexec --fs-events create -- s3 sync . s3://my-bucket

# ignore
# $ watchexec -i "target/**" make test
